package controller;
import Utils.ConstantUtils;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import entity.SysRoles;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import service.SysRolesService;

import javax.annotation.Resource;

/**
 * 角色(SysRolesVo)表控制层
 *
 * @author liujh
 * @since 2020-08-10 17:01:35
 */
@Controller
@RequestMapping("sysRoles")
public class SysRolesController {
    /**
     * 服务对象
     */
    @Resource
    private SysRolesService sysRolesService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public SysRoles selectOne(Long id) {
        return this.sysRolesService.queryById(id);
    }


    @GetMapping(value = "list")
    @DS("db2")
    public Object findList(@RequestParam(name = "pageNum",defaultValue = "1")int pageNum,
                           @RequestParam(name = "pageSize",defaultValue = "5")int pageSize, Model m){
        Page sysRolePage = (Page) sysRolesService.queryAllByLimit(pageNum,pageSize);
        m.addAttribute("dataPage",sysRolePage);
        m.addAttribute("path", ConstantUtils.MENU_JUMP_HREF_ROLE);
        return "sys/role/list::rolelist";
    }
}